#ifndef SQLMODEL_H
#define SQLMODEL_H

#include <QtSql/QSqlRelationalTableModel>

class SqlTableModel: public QSqlRelationalTableModel
{
    Q_OBJECT
    Q_PROPERTY(bool readOnly WRITE setReadOnly)

public:
    explicit SqlTableModel(QObject *parent = 0,  QSqlDatabase db = QSqlDatabase());
    virtual ~SqlTableModel();

    Q_INVOKABLE void setTable(const QString &table);

    QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const;
    Qt::ItemFlags flags(const QModelIndex &index) const;

    void setReadOnly(bool readOnly) { m_readOnly = readOnly;}

private:
    QHash<QString, QVariant::Type> m_fieldsType;
    bool m_readOnly;
};
#endif // SQLMODEL_H
